package com.yc.demo.vo;


import com.yc.demo.common.enums.ErrorCode;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>响应体</p>
 *
 * @author YuanChilde
 * @version 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2019-09-18 17:25    YuanChilde     1.0        新增
 * @date 2019-09-18 17:25
 */
public class ResultBody extends HashMap<String, Object> {

    private static final long serialVersionUID = -7863617337695452479L;

    public static ResultBody error() {
        return error(ErrorCode.FAIL.getCode(), ErrorCode.FAIL.getMessage());
    }

    public static ResultBody error(String msg) {
        return error(ErrorCode.FAIL.getCode(), msg);
    }

    public static ResultBody error(int code, String msg) {
        ResultBody r = new ResultBody();
        r.put("errorCode", code);
        r.put("errorMessage", msg);
        return r;
    }

    public static ResultBody ok() {
        ResultBody r = new ResultBody();
        r.put("errorCode", ErrorCode.OK.getCode());
        return r;
    }

    public ResultBody put(Map<String, Object> map) {
        super.putAll(map);
        return this;
    }

    @Override
    public ResultBody put(String key, Object value) {
        super.put(key, value);
        return this;
    }

}
